home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume5 / smallc / part3 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  52.7 KB

  1. Subject: Small C compiler version C3.0R1.1 (part 3 of 3)
  2. Newsgroups: mod.sources
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 5, Issue 9
  6. Submitted by: genrad!linus!mnetor!clewis (Chris Lewis)
  7.  
  8. #! /bin/sh
  9. # This is a shell archive, meaning:
  10. # 1. Remove everything above the #! /bin/sh line.
  11. # 2. Save the resulting text in a file.
  12. # 3. Execute the file with /bin/sh (not csh) to create the files:
  13. #    includes
  14. #    6809
  15. #    8080
  16. #    vax
  17. #    lib
  18. # This archive created: Sun May 18 18:20:19 1986
  19. export PATH; PATH=/bin:$PATH
  20. if test ! -d 'includes'
  21. then
  22.     echo shar: creating directory "'includes'"
  23.     mkdir 'includes'
  24. fi
  25. echo shar: extracting "'includes/ctype.h'" '(34 characters)'
  26. if test -f 'includes/ctype.h'
  27. then
  28.     echo shar: will not over-write existing file "'includes/ctype.h'"
  29. else
  30. cat << \SHAR_EOF > 'includes/ctype.h'
  31. /*    Nothing needed in this file */
  32. SHAR_EOF
  33. if test 34 -ne "`wc -c < 'includes/ctype.h'`"
  34. then
  35.     echo shar: error transmitting "'includes/ctype.h'" '(should have been 34 characters)'
  36. fi
  37. fi
  38. echo shar: extracting "'includes/stdio.h'" '(100 characters)'
  39. if test -f 'includes/stdio.h'
  40. then
  41.     echo shar: will not over-write existing file "'includes/stdio.h'"
  42. else
  43. cat << \SHAR_EOF > 'includes/stdio.h'
  44. #define stdin 0
  45. #define stdout 1
  46. #define stderr 2
  47. #define NULL 0
  48. #define EOF (-1)
  49. #define FILE char
  50. SHAR_EOF
  51. if test 100 -ne "`wc -c < 'includes/stdio.h'`"
  52. then
  53.     echo shar: error transmitting "'includes/stdio.h'" '(should have been 100 characters)'
  54. fi
  55. fi
  56. echo shar: done with directory "'includes'"
  57. if test ! -d '6809'
  58. then
  59.     echo shar: creating directory "'6809'"
  60.     mkdir '6809'
  61. fi
  62. echo shar: extracting "'6809/ccstart.u'" '(373 characters)'
  63. if test -f '6809/ccstart.u'
  64. then
  65.     echo shar: will not over-write existing file "'6809/ccstart.u'"
  66. else
  67. cat << \SHAR_EOF > '6809/ccstart.u'
  68. |    Run-time start off for ccv1 on the Physics 6809
  69. .globl    _edata
  70. .globl    _main
  71. | Initialize stack
  72.     lds    #/1000
  73.     ldx    #_edata    | clear all of memory
  74. l2:    clr    (x)+
  75.     cmpx    #/0fff
  76.     bne    l2
  77. | Circumvent EPROM bug
  78.     ldx    #/ff3b
  79.     ldb    #6
  80. l1:    pshs    x
  81.     decb
  82.     bne l1
  83. |    clear everything so that start conds are
  84. |    always same
  85.     clra
  86.     clrb
  87.     tfr    a,dp
  88.     tfr    d,x
  89.     tfr    d,y
  90.     tfr    d,u
  91.     jsr    _main
  92.     jmp    /fc00
  93. SHAR_EOF
  94. if test 373 -ne "`wc -c < '6809/ccstart.u'`"
  95. then
  96.     echo shar: error transmitting "'6809/ccstart.u'" '(should have been 373 characters)'
  97. fi
  98. fi
  99. echo shar: extracting "'6809/crunas09.u'" '(884 characters)'
  100. if test -f '6809/crunas09.u'
  101. then
  102.     echo shar: will not over-write existing file "'6809/crunas09.u'"
  103. else
  104. cat << \SHAR_EOF > '6809/crunas09.u'
  105. |    csa09 Small C v1 comparison support
  106. |    All are dyadic except for lneg.
  107. .globl    eq
  108. .globl    ne
  109. .globl    lt
  110. .globl    le
  111. .globl    gt
  112. .globl    ge
  113. .globl    ult
  114. .globl    ule
  115. .globl    ugt
  116. .globl    uge
  117. .globl    lneg
  118. .globl    bool
  119. .globl    _eend,_edata,_etext
  120. .globl    _Xstktop,_brkend
  121.  
  122. eq:    cmpd 2(s)
  123.     lbeq true
  124.     lbra false
  125.  
  126. ne:    cmpd 2(s)
  127.     lbne true
  128.     lbra false
  129.  
  130. lt:    cmpd 2(s)
  131.     bgt true
  132.     bra false
  133.  
  134. le:    cmpd 2(s)
  135.     bge true
  136.     bra false
  137.  
  138. gt:    cmpd 2(s)
  139.     blt true
  140.     bra false
  141.  
  142. ge:    cmpd 2(s)
  143.     ble true
  144.     bra false
  145.  
  146. ult:    cmpd 2(s)
  147.     bhi true
  148.     bra false
  149.  
  150. ule:    cmpd 2(s)
  151.     bhs true
  152.     bra false
  153.  
  154. ugt:    cmpd 2(s)
  155.     blo true
  156.     bra false
  157.  
  158. uge:    cmpd 2(s)
  159.     bls true
  160.     bra false
  161.  
  162. lneg:    cmpd #0
  163.     beq ltrue
  164.     ldd #0
  165.     rts
  166. ltrue:    ldd #1
  167.     rts
  168.  
  169. bool:    bsr    lneg
  170.     bra    lneg
  171.  
  172. true:    ldd #1
  173.     ldx (s)
  174.     leas 4(s)
  175.     jmp (x)
  176.  
  177. false:    clra
  178.     clrb
  179.     ldx (s)
  180.     leas 4(s)
  181.     jmp  (x)
  182. _Xstktop:    tfr    s,d
  183.     rts
  184. _etext    =    .
  185.     .bss
  186. _eend    =    .
  187.     .data
  188. _brkend:    .wval    _eend
  189. _edata    =    .
  190. SHAR_EOF
  191. if test 884 -ne "`wc -c < '6809/crunas09.u'`"
  192. then
  193.     echo shar: error transmitting "'6809/crunas09.u'" '(should have been 884 characters)'
  194. fi
  195. fi
  196. echo shar: extracting "'6809/exit.u'" '(75 characters)'
  197. if test -f '6809/exit.u'
  198. then
  199.     echo shar: will not over-write existing file "'6809/exit.u'"
  200. else
  201. cat << \SHAR_EOF > '6809/exit.u'
  202. |    Small C v1 exit routine (physics computer)
  203. .globl    _exit
  204. _exit:    jmp    /fc00
  205. SHAR_EOF
  206. if test 75 -ne "`wc -c < '6809/exit.u'`"
  207. then
  208.     echo shar: error transmitting "'6809/exit.u'" '(should have been 75 characters)'
  209. fi
  210. fi
  211. echo shar: extracting "'6809/faults.u'" '(205 characters)'
  212. if test -f '6809/faults.u'
  213. then
  214.     echo shar: will not over-write existing file "'6809/faults.u'"
  215. else
  216. cat << \SHAR_EOF > '6809/faults.u'
  217. |    MC6809 Concurrent Euclid fault codes
  218. ASSERTFAIL = 0
  219. RANGECHECK = 1
  220. CASERANGE = 2
  221. | fault codes for runtime routines
  222. OUTOFSPACE = 20
  223. .globl ASSERTFAIL
  224. .globl RANGECHECK
  225. .globl CASERANGE
  226. .globl    OUTOFSPACE
  227. SHAR_EOF
  228. if test 205 -ne "`wc -c < '6809/faults.u'`"
  229. then
  230.     echo shar: error transmitting "'6809/faults.u'" '(should have been 205 characters)'
  231. fi
  232. fi
  233. echo shar: extracting "'6809/io.u'" '(334 characters)'
  234. if test -f '6809/io.u'
  235. then
  236.     echo shar: will not over-write existing file "'6809/io.u'"
  237. else
  238. cat << \SHAR_EOF > '6809/io.u'
  239. |    Small C v1 io (putchar) for physics machine
  240. .globl    _putchar
  241. _putchar=.
  242.     lda    /9000
  243.     bita    #2
  244.     beq    _putchar
  245.     lda    3(s)
  246.     sta    /9001
  247.     cmpa    #10.
  248.     bne    out
  249.     ldd    #13.
  250.     pshs    d
  251.     lbsr    _putchar
  252.     leas    2(s)
  253. out:    rts
  254.  
  255. .globl    _getchar
  256. _getchar=.
  257.     lda    /9000
  258.     bita    #1
  259.     beq    _getchar
  260.     ldb    /9001
  261.     clra
  262.     andb    #/7F
  263.     cmpb    #04
  264.     bne    noteot
  265.     ldd    #-1
  266. noteot:    rts
  267. SHAR_EOF
  268. if test 334 -ne "`wc -c < '6809/io.u'`"
  269. then
  270.     echo shar: error transmitting "'6809/io.u'" '(should have been 334 characters)'
  271. fi
  272. fi
  273. echo shar: extracting "'6809/mrabs.u'" '(422 characters)'
  274. if test -f '6809/mrabs.u'
  275. then
  276.     echo shar: will not over-write existing file "'6809/mrabs.u'"
  277. else
  278. cat << \SHAR_EOF > '6809/mrabs.u'
  279. |    mrabs.  converts both args to unsigned, and
  280. |    remembers result sign as the sign of the left
  281. |    argument.  (for signed modulo)
  282. |    result d contains right, sign is non-zero
  283. |    if result (from mod) should be negative.
  284. |
  285. |
  286. .globl mrabs
  287.     left=8.
  288.     right=4.
  289.     sign=3.
  290. mrabs:    clr    sign(s)
  291.     ldd    left(s)
  292.     bge    tryr
  293.     nega
  294.     negb
  295.     sbca    #0
  296.     std    left(s)
  297.     inc    sign(s)
  298. tryr:    ldd    right(s)
  299.     bge    done
  300.     nega
  301.     negb
  302.     sbca    #0
  303.     std    right(s)
  304. done:    rts
  305. SHAR_EOF
  306. if test 422 -ne "`wc -c < '6809/mrabs.u'`"
  307. then
  308.     echo shar: error transmitting "'6809/mrabs.u'" '(should have been 422 characters)'
  309. fi
  310. fi
  311. echo shar: extracting "'6809/prabs.u'" '(432 characters)'
  312. if test -f '6809/prabs.u'
  313. then
  314.     echo shar: will not over-write existing file "'6809/prabs.u'"
  315. else
  316. cat << \SHAR_EOF > '6809/prabs.u'
  317. |    prabs.  converts both args to unsigned, and
  318. |    remembers result sign as sign a eor sign b
  319. |    used only by divide support
  320. |    result d contains right, sign is non-zero
  321. |    if result (from divide) should be negative.
  322. |
  323. |
  324. .globl prabs
  325.     left=8.
  326.     right=4.
  327.     sign=3.
  328. prabs:    clr    sign(s)
  329.     ldd    left(s)
  330.     bge    tryr
  331.     nega
  332.     negb
  333.     sbca    #0
  334.     std    left(s)
  335.     inc    sign(s)
  336. tryr:    ldd    right(s)
  337.     bge    done
  338.     nega
  339.     negb
  340.     sbca    #0
  341.     dec    sign(s)
  342.     std    right(s)
  343. done:    rts
  344. SHAR_EOF
  345. if test 432 -ne "`wc -c < '6809/prabs.u'`"
  346. then
  347.     echo shar: error transmitting "'6809/prabs.u'" '(should have been 432 characters)'
  348. fi
  349. fi
  350. echo shar: extracting "'6809/sdiv.u'" '(812 characters)'
  351. if test -f '6809/sdiv.u'
  352. then
  353.     echo shar: will not over-write existing file "'6809/sdiv.u'"
  354. else
  355. cat << \SHAR_EOF > '6809/sdiv.u'
  356. |    signed divide
  357. |    calling: (left / right)
  358. |        push left
  359. |        ldd right
  360. |        jsr sdiv
  361. |    result in d, arg popped.
  362. |
  363.     left=6
  364.     right=2
  365.     sign=1
  366.     count=0
  367.     return=4
  368.     CARRY=1
  369. .globl sdiv,div,ASSERTFAIL
  370. .globl prabs
  371. sdiv:    leas    -4(s)
  372.     std    right(s)
  373.     bne    nozero
  374.     swi2
  375.     .byte    ASSERTFAIL
  376. nozero:    jsr    prabs
  377. div:    clr    count(s)    | prescale divisor
  378.     inc    count(s)
  379. mscl:    inc    count(s)
  380.     aslb
  381.     rola
  382.     bpl    mscl
  383.     std    right(s)
  384.     ldd    left(s)
  385.     clr    left(s)
  386.     clr    left+1(s)
  387. div1:    subd    right(s)    | check subtract
  388.     bcc    div2
  389.     addd    right(s)
  390.     andcc    #~CARRY
  391.     bra    div3
  392. div2:    orcc    #CARRY
  393. div3:    rol    left+1(s)    | roll in carry
  394.     rol    left(s)
  395.     lsr    right(s)
  396.     ror    right+1(s)
  397.     dec    count(s)
  398.     bne    div1
  399.     ldd    left(s)
  400.     tst    sign(s)        | sign fiddle
  401.     beq    nochg
  402.     nega
  403.     negb
  404.     sbca    #0
  405. nochg:    std    right(s)    | move return addr
  406.     ldd    return(s)
  407.     std    left(s)
  408.     ldd    right(s)
  409.     leas    6(s)
  410.     rts
  411. SHAR_EOF
  412. if test 812 -ne "`wc -c < '6809/sdiv.u'`"
  413. then
  414.     echo shar: error transmitting "'6809/sdiv.u'" '(should have been 812 characters)'
  415. fi
  416. fi
  417. echo shar: extracting "'6809/shift.u'" '(317 characters)'
  418. if test -f '6809/shift.u'
  419. then
  420.     echo shar: will not over-write existing file "'6809/shift.u'"
  421. else
  422. cat << \SHAR_EOF > '6809/shift.u'
  423. |    Shift support for Small C v1 sa09
  424. .globl    asr
  425. asr:    tstb
  426.     bge    okr
  427.     negb
  428.     bra    asl
  429. okr:    incb
  430.     pshs    b
  431.     ldd    3(s)
  432. asrl:    dec    (s)
  433.     beq    return
  434.     asra
  435.     rorb
  436.     bra    asrl
  437.  
  438. .globl    asl
  439. asl:    tstb
  440.     bge    okl
  441.     negb
  442.     bra    asr
  443. okl:    incb
  444.     pshs    b
  445.     ldd    3(s)
  446. asll:    dec    (s)
  447.     beq    return
  448.     aslb
  449.     rola
  450.     bra    asll
  451.  
  452. return:    ldx    1(s)
  453.     leas    5(s)
  454.     jmp    (x)
  455. SHAR_EOF
  456. if test 317 -ne "`wc -c < '6809/shift.u'`"
  457. then
  458.     echo shar: error transmitting "'6809/shift.u'" '(should have been 317 characters)'
  459. fi
  460. fi
  461. echo shar: extracting "'6809/smod.u'" '(796 characters)'
  462. if test -f '6809/smod.u'
  463. then
  464.     echo shar: will not over-write existing file "'6809/smod.u'"
  465. else
  466. cat << \SHAR_EOF > '6809/smod.u'
  467. |    signed mod
  468. |    calling: (left / right)
  469. |        push left
  470. |        ldd right
  471. |        jsr smod
  472. |    result in d, arg popped.
  473. |
  474.     left=6
  475.     right=2
  476.     sign=1
  477.     count=0
  478.     return=4
  479.     CARRY=1
  480. .globl smod,mod,ASSERTFAIL
  481. .globl mrabs
  482. smod:    leas    -4(s)
  483.     std    right(s)
  484.     bne    nozero
  485.     swi2
  486.     .byte    ASSERTFAIL
  487. nozero:    jsr    mrabs
  488. mod:    clr    count(s)    | prescale divisor
  489.     inc    count(s)
  490. mscl:    inc    count(s)
  491.     aslb
  492.     rola
  493.     bpl    mscl
  494.     std    right(s)
  495.     ldd    left(s)
  496.     clr    left(s)
  497.     clr    left+1(s)
  498. mod1:    subd    right(s)    | check subtract
  499.     bcc    mod2
  500.     addd    right(s)
  501.     andcc    #~CARRY
  502.     bra    mod3
  503. mod2:    orcc    #CARRY
  504. mod3:    rol    left+1(s)    | roll in carry
  505.     rol    left(s)
  506.     lsr    right(s)
  507.     ror    right+1(s)
  508.     dec    count(s)
  509.     bne    mod1
  510.     tst    sign(s)        | sign fiddle
  511.     beq    nochg
  512.     nega
  513.     negb
  514.     sbca    #0
  515. nochg:    std    right(s)    | move return addr
  516.     ldd    return(s)
  517.     std    left(s)
  518.     ldd    right(s)
  519.     leas    6(s)
  520.     rts
  521. SHAR_EOF
  522. if test 796 -ne "`wc -c < '6809/smod.u'`"
  523. then
  524.     echo shar: error transmitting "'6809/smod.u'" '(should have been 796 characters)'
  525. fi
  526. fi
  527. echo shar: extracting "'6809/sumul.u'" '(591 characters)'
  528. if test -f '6809/sumul.u'
  529. then
  530.     echo shar: will not over-write existing file "'6809/sumul.u'"
  531. else
  532. cat << \SHAR_EOF > '6809/sumul.u'
  533. |    signed/unsigned multiply
  534. |    calling (left * right)
  535. |    push left
  536. |    ldd right
  537. |    jsr [u|s]mul (same entry point)
  538. |    result in d, stack is popped
  539. .globl smul,umul
  540. smul=.
  541. umul:    pshs    d
  542.     lda    2+2(s)
  543.     mul        | left msb * right lsb
  544.     pshs    b    | save high order
  545.     ldb    -1+3(s)    | right lsb
  546.     lda    3+3(s)    | left lsb
  547.     mul
  548.     pshs    d
  549.     lda    3+5(s)    | left lsb
  550.     ldb    -2+5(s)    | right msb
  551.     beq    small    | is zero?
  552.     mul        | no, gotta do it too
  553.     tfr    b,a
  554.     clrb
  555.     addd    (s)++    | partial prod
  556.     bra    big
  557. small:    puls    d    | aha! don't need third mul
  558. big:    adda    (s)+
  559.     pshs    d
  560.     ldd    4(s)    | rearrange return address
  561.     std    6(s)
  562.     puls    d
  563.     leas    4(s)
  564.     rts
  565. SHAR_EOF
  566. if test 591 -ne "`wc -c < '6809/sumul.u'`"
  567. then
  568.     echo shar: error transmitting "'6809/sumul.u'" '(should have been 591 characters)'
  569. fi
  570. fi
  571. echo shar: done with directory "'6809'"
  572. if test ! -d '8080'
  573. then
  574.     echo shar: creating directory "'8080'"
  575.     mkdir '8080'
  576. fi
  577. echo shar: extracting "'8080/Makefile'" '(129 characters)'
  578. if test -f '8080/Makefile'
  579. then
  580.     echo shar: will not over-write existing file "'8080/Makefile'"
  581. else
  582. cat << \SHAR_EOF > '8080/Makefile'
  583. .SUFFIXES:    .o .c .asm
  584.  
  585. ASSEMS = bdos.asm bdos1.asm chio8080.asm exit.asm io8080.asm sbrk.asm
  586.  
  587. .c.asm:
  588.     tscc    $*.c
  589.  
  590. all:    $(ASSEMS)
  591. SHAR_EOF
  592. if test 129 -ne "`wc -c < '8080/Makefile'`"
  593. then
  594.     echo shar: error transmitting "'8080/Makefile'" '(should have been 129 characters)'
  595. fi
  596. fi
  597. echo shar: extracting "'8080/arglist.c'" '(667 characters)'
  598. if test -f '8080/arglist.c'
  599. then
  600.     echo shar: will not over-write existing file "'8080/arglist.c'"
  601. else
  602. cat << \SHAR_EOF > '8080/arglist.c'
  603. /*    Interpret CPM argument list to produce C style
  604.     argc/argv
  605.     default dma buffer has it, form:
  606.     ---------------------------------
  607.     |count|characters  ...          |
  608.     ---------------------------------
  609. */
  610. int    Xargc;
  611. int    Xargv[30];
  612. Xarglist(ap) char *ap; {
  613.     char qc;
  614.     Xargc = 0;
  615.     ap[(*ap)+1] = '\0';
  616.     ap++;
  617.     while (isspace(*ap)) ap++;
  618.     Xargv[Xargc++] = "arg0";
  619.     if (*ap)
  620.         do {
  621.             if (*ap == '\'' || *ap == '\"') {
  622.                 qc = *ap;
  623.                 Xargv[Xargc++] = ++ap;
  624.                 while (*ap&&*ap != qc) ap++;
  625.             } else {
  626.                 Xargv[Xargc++] = ap;
  627.                 while (*ap&&!isspace(*ap)) ap++;
  628.             }
  629.             if (!*ap) break;
  630.             *ap++='\0';
  631.             while (isspace(*ap)) ap++;
  632.         } while(*ap);
  633.     Xargv[Xargc] = 0;
  634. }
  635. SHAR_EOF
  636. if test 667 -ne "`wc -c < '8080/arglist.c'`"
  637. then
  638.     echo shar: error transmitting "'8080/arglist.c'" '(should have been 667 characters)'
  639. fi
  640. fi
  641. echo shar: extracting "'8080/bdos.c'" '(279 characters)'
  642. if test -f '8080/bdos.c'
  643. then
  644.     echo shar: will not over-write existing file "'8080/bdos.c'"
  645. else
  646. cat << \SHAR_EOF > '8080/bdos.c'
  647. bdos (c, de) int c, de; {
  648. #asm
  649. ;    CP/M support routine
  650. ;    bdos(C,DE);
  651. ;    char *DE; int C;
  652. ;    returns H=B,L=A per CPM standard
  653.     pop    h    ; hold return address
  654.     pop    d    ; get bdos function number
  655.     pop    b    ; get DE register argument
  656.     push    d
  657.     push    b
  658.     push    h
  659.     call    5
  660.     mov    h,b
  661.     mov    l,a
  662. #endasm
  663. }
  664. SHAR_EOF
  665. if test 279 -ne "`wc -c < '8080/bdos.c'`"
  666. then
  667.     echo shar: error transmitting "'8080/bdos.c'" '(should have been 279 characters)'
  668. fi
  669. fi
  670. echo shar: extracting "'8080/bdos1.c'" '(105 characters)'
  671. if test -f '8080/bdos1.c'
  672. then
  673.     echo shar: will not over-write existing file "'8080/bdos1.c'"
  674. else
  675. cat << \SHAR_EOF > '8080/bdos1.c'
  676. bdos1(c, de) int c, de; {
  677.     /* returns only single byte (top half is 0) */
  678.     return (255 & bdos(c, de));
  679. }
  680. SHAR_EOF
  681. if test 105 -ne "`wc -c < '8080/bdos1.c'`"
  682. then
  683.     echo shar: error transmitting "'8080/bdos1.c'" '(should have been 105 characters)'
  684. fi
  685. fi
  686. echo shar: extracting "'8080/chio8080.c'" '(125 characters)'
  687. if test -f '8080/chio8080.c'
  688. then
  689.     echo shar: will not over-write existing file "'8080/chio8080.c'"
  690. else
  691. cat << \SHAR_EOF > '8080/chio8080.c'
  692. #define EOL 10
  693. getchar() {
  694.     return (bdos(1,1));
  695. }
  696.  
  697. putchar (c) char c; {
  698.     if (c == EOL)    bdos(2,13);
  699.     bdos(2,c);
  700.     return c;
  701. }
  702. SHAR_EOF
  703. if test 125 -ne "`wc -c < '8080/chio8080.c'`"
  704. then
  705.     echo shar: error transmitting "'8080/chio8080.c'" '(should have been 125 characters)'
  706. fi
  707. fi
  708. echo shar: extracting "'8080/exit.c'" '(51 characters)'
  709. if test -f '8080/exit.c'
  710. then
  711.     echo shar: will not over-write existing file "'8080/exit.c'"
  712. else
  713. cat << \SHAR_EOF > '8080/exit.c'
  714. exit(retcode) int retcode; {
  715. #asm
  716.     jmp    0
  717. #endasm
  718. }
  719. SHAR_EOF
  720. if test 51 -ne "`wc -c < '8080/exit.c'`"
  721. then
  722.     echo shar: error transmitting "'8080/exit.c'" '(should have been 51 characters)'
  723. fi
  724. fi
  725. echo shar: extracting "'8080/inout.c'" '(257 characters)'
  726. if test -f '8080/inout.c'
  727. then
  728.     echo shar: will not over-write existing file "'8080/inout.c'"
  729. else
  730. cat << \SHAR_EOF > '8080/inout.c'
  731. inp(pno) char pno; {
  732.     pno;
  733. #asm
  734.     mov    a,l
  735.     sta    ininst+1
  736. ininst    in    0    ; self modifying code...
  737.     mov    l,a
  738.     xra    a
  739.     mov    h,a
  740.     ret
  741. #endasm
  742. }
  743.  
  744. outp(pno, val) char pno, val; {
  745.     pno;
  746. #asm
  747.     mov    a,l
  748.     sta    outinst+1
  749. #endasm
  750.     val;
  751. #asm
  752.     mov    a,l
  753. outinst    out    0
  754.     ret
  755. #endasm
  756. }
  757. SHAR_EOF
  758. if test 257 -ne "`wc -c < '8080/inout.c'`"
  759. then
  760.     echo shar: error transmitting "'8080/inout.c'" '(should have been 257 characters)'
  761. fi
  762. fi
  763. echo shar: extracting "'8080/io8080.c'" '(6129 characters)'
  764. if test -f '8080/io8080.c'
  765. then
  766.     echo shar: will not over-write existing file "'8080/io8080.c'"
  767. else
  768. cat << \SHAR_EOF > '8080/io8080.c'
  769. /*    Basic CP/M file I/O:
  770. fopen,fclose,fgetc,fputc,feof
  771.  
  772. Original:    Paul Tarvydas
  773. Fixed by:    Chris Lewis
  774. */
  775. #include <stdio.h>
  776.  
  777. #define EOL 10
  778. #define EOL2 13
  779. #define CPMEOF 26
  780. #define CPMERR 255
  781. #define UNIT_OFFSET 3
  782. #define CPMCIN 1
  783. #define CPMCOUT 2
  784. #define READ_EOF 3
  785. #define SETDMA 26
  786. #define DEFAULT_DMA 128
  787. #define CPMREAD 20
  788. #define CPMWR 21
  789. #define WRITE 2
  790. #define READ 1
  791. #define FREE 0
  792. #define NBUFFS 4
  793. #define BUFSIZ 512
  794. #define FCBSIZ 33
  795. #define ALLBUFFS 2048
  796. #define ALLFCBS 132
  797. #define CPMERA 19
  798. #define CPMCREAT 22
  799. #define CPMOPEN 15
  800. #define NBLOCKS 4
  801. #define BLKSIZ 128
  802. #define BKSP 8
  803. #define CTRLU 21
  804. #define FWSP ' '
  805. #define CPMCLOSE 16
  806.  
  807. char     buffs[ALLBUFFS],    /* disk buffers */
  808. fcbs[ALLFCBS];        /* fcbs for buffers */
  809. int    bptr[NBUFFS];        /* ptrs into buffers */
  810. int    modes[NBUFFS];        /* mode for each open file */
  811. int    eptr[NBUFFS];        /* buffers' ends */
  812. char eofstdin;    /* flag end of file on stdin */
  813.  
  814. fgetc(unit) int unit; 
  815. {
  816.     int c;
  817.     while ((c = Xfgetc(unit)) == EOL2);
  818.     return c;
  819. }
  820. Xfgetc(unit) int unit; 
  821. {
  822.     int i;
  823.     int c;
  824.     char *buff;
  825.     char *fcba;
  826.     if ((unit == stdin) & !eofstdin) {
  827.     c = bdos1(CPMCIN, 0);
  828.     if (c == 4) {
  829.         eofstdin = 1;
  830.         return (EOF);
  831.     }
  832.     else if (c == 3)
  833.         exit (1);
  834.     else {
  835.         if (c == EOL2) {
  836.         c = EOL;
  837.         bdos (CPMCOUT, EOL);
  838.         }
  839.         return (c);
  840.     }
  841.     }
  842.     if (modes[unit = unit - UNIT_OFFSET] == READ) {
  843.     if (bptr[unit] >= eptr[unit]) {
  844.         fcba = fcbaddr(unit);
  845.         /* fill da buffer again */
  846.         i = 0;  /* block counter */
  847.         buff = buffaddr(unit); /* dma ptr */
  848.         /* if buffer wasn't totally
  849.                 filled last time, we already
  850.                 eof */
  851.         if (eptr[unit] == buffaddr(unit + 1))
  852.         do {
  853.         bdos(SETDMA, buff);
  854.         if (0!=bdos1(CPMREAD, fcba))
  855.             break;
  856.         buff = buff + BLKSIZ;
  857.         }
  858.         while (++i<NBLOCKS);
  859.         bdos(SETDMA, DEFAULT_DMA);
  860.         /* if i still 0, no blocks read =>eof*/
  861.         if (i==0) {
  862.         modes[unit] = READ_EOF;
  863.         return EOF;
  864.         }
  865.         /* o.k. set start & end ptrs */
  866.         eptr[unit] =
  867.         (bptr[unit]=buffaddr(unit))
  868.         + (i * BLKSIZ);
  869.     }
  870.     c = (*(bptr[unit]++)) & 0xff;
  871.     if (c == CPMEOF) {
  872.         c = EOF;
  873.         modes[unit] = READ_EOF;
  874.     }
  875.     return c;
  876.     }
  877.     return EOF;
  878. }
  879.  
  880. fclose(unit) int unit; 
  881. {
  882.     int i;
  883.     if ((unit==stdin)|(unit==stdout)|(unit==stderr))
  884.     return NULL;
  885.     if (modes[unit = unit - UNIT_OFFSET] != FREE) {
  886.     if (modes[unit] == WRITE)
  887.         fflush(unit + UNIT_OFFSET);
  888.     modes[unit] = FREE;
  889.     return bdos1(CPMCLOSE, fcbaddr(unit));
  890.     }
  891.     return EOF;
  892. }
  893.  
  894. fflush(unit) int unit; 
  895. {
  896.     char *buffa;
  897.     char *fcba;
  898.     if ((unit!=stdin)|(unit!=stdout)|(unit!=stderr)) {
  899.     /* put an eof at end of file */
  900.     fputc(CPMEOF, unit);
  901.     if (bptr[unit = unit - UNIT_OFFSET] !=
  902.         (buffa = buffaddr(unit))) {
  903.         /* some chars in buffer - flush them */
  904.         fcba = fcbaddr(unit);
  905.         do {
  906.         bdos(SETDMA, buffa);
  907.         if (0 != bdos1(CPMWR, fcba))
  908.             return (EOF);
  909.         }
  910.         while (bptr[unit] >
  911.         (buffa=buffa+BLKSIZ));
  912.         bdos(SETDMA, DEFAULT_DMA);
  913.     }
  914.     }
  915.     return NULL;
  916. }
  917.  
  918. fputc(c, unit) char c; 
  919. int unit; 
  920.     char *buffa;
  921.     char *fcba;
  922.     if (c == EOL) fputc(EOL2, unit);
  923.     if ((unit == stdout) | (unit == stderr)) {
  924.     bdos(CPMCOUT, c);
  925.     return c;
  926.     }
  927.     if (WRITE == modes[unit = unit - UNIT_OFFSET]) {
  928.     if (bptr[unit] >= eptr[unit]) {
  929.         /* no room - dump buffer */
  930.         fcba = fcbaddr(unit);
  931.         buffa=buffaddr(unit);
  932.         while (buffa < eptr[unit]) {
  933.         bdos(SETDMA, buffa);
  934.         if (0 != bdos1(CPMWR, fcba)) break;
  935.         buffa = buffa + BLKSIZ;
  936.         }
  937.         bdos(SETDMA, DEFAULT_DMA);
  938.         bptr[unit] = buffaddr(unit);
  939.         if (buffa < eptr[unit]) return EOF;
  940.     }
  941.     *(bptr[unit]++) = c;
  942.     return c;
  943.     }
  944.     return EOF;
  945. }
  946.  
  947. allocunitno() { 
  948.     int i;
  949.     /* returns # of first free buffer, EOF if none */
  950.     /* buffer is not reserved (ie. mode remains FREE) */
  951.     for (i = 0; i < NBUFFS; ++i)
  952.     if (modes[i] == FREE) break;
  953.     if (i >= NBUFFS) return EOF;
  954.     else return (i + UNIT_OFFSET);
  955. }
  956.  
  957. fopen(name, mode) char *name, *mode; 
  958.     int fileno, fno2;
  959.     if (EOF != (fileno = allocunitno())) {
  960.     /* internal file # excludes units 0,1 & 2
  961.         since there's no buffers associated with
  962.         these units */
  963.     movname(clearfcb(fcbaddr(fno2 = fileno
  964.         - UNIT_OFFSET)), name);
  965.     if ('r' == *mode) {
  966.         if (bdos1(CPMOPEN, fcbaddr(fno2)) != CPMERR)
  967.         { 
  968.         modes[fno2] = READ;
  969.         /* ptr>bufsiz => buffer empty*/
  970.         eptr[fno2] =
  971.             bptr[fno2] = buffaddr(fno2+1);
  972.         return fileno;
  973.         }
  974.     } 
  975.     else if ('w' == *mode) {
  976.         bdos(CPMERA, fcbaddr(fno2));
  977.         if (bdos1(CPMCREAT, fcbaddr(fno2)) != CPMERR){
  978.         modes[fno2] = WRITE;
  979.         bptr[fno2] = buffaddr(fno2);
  980.         eptr[fno2] = buffaddr(fno2+1);
  981.         return fileno;
  982.         }
  983.     }
  984.     }
  985.     return NULL;
  986. }
  987.  
  988. clearfcb(fcb) char fcb[]; 
  989.     int i;
  990.     for (i=0; i<FCBSIZ; fcb[i++] = 0);
  991.     /* blank out name field */
  992.     for (i=1; i<12; fcb[i++] = ' ');
  993.     return fcb;
  994. }
  995.  
  996. movname(fcb, str) char fcb[], *str; 
  997. {
  998.     int i; 
  999.     char c;
  1000.     i = 1; /* first char of name @ pos 1 */
  1001.     *fcb = 0;
  1002.     if (':' == str[1]) {
  1003.     c = toupper(str[0]);
  1004.     if (('A' <= c) & ('B' >= c)) {
  1005.         *fcb = (c - 'A' + 1);
  1006.         str++;
  1007.         str++;
  1008.     }
  1009.     }
  1010.     while ((NULL != *str) & (i<9)) {
  1011.     /* up to 8 chars into file name field */
  1012.     if ('.' == *str) break;
  1013.     fcb[i++] = toupper(*str++);
  1014.     }
  1015.     /* strip off excess chars - up to '.' (beginning of
  1016.     extension name ) */
  1017.     while ((NULL != *str) & ((*str) != '.')) ++str;
  1018.     if (*str)
  1019.     /* '.' is first char of *str now */
  1020.     /* copy 3 chars of ext. if there */
  1021.     for (    /* first char of ext @ pos 9 (8+1)*/
  1022. i = 8;
  1023. /* '.' is stripped by ++ 1st time */
  1024. /* around */
  1025. (NULL != *++str) & (12 > ++i);
  1026. fcb[i] = toupper(*str)
  1027. );
  1028.     return fcb;
  1029. }
  1030.  
  1031. stdioinit() {
  1032.     int i;
  1033.     eofstdin = 0;
  1034.     for (i=0; i<NBUFFS; modes[i++] = FREE);
  1035. }
  1036.  
  1037. fcbaddr(unit) int unit; 
  1038. {
  1039.     /* returns address of fcb associated with given unit -
  1040.     unit taken with origin 0 (ie. std's not included) */
  1041.     return &fcbs[unit * FCBSIZ];
  1042. }
  1043.  
  1044. buffaddr(unit) int unit; 
  1045. {
  1046.     return &buffs[unit * BUFSIZ];
  1047. }
  1048.  
  1049. feof (unit) FILE *unit; 
  1050. {
  1051.     if ((unit == stdin) & eofstdin)
  1052.     return 1;
  1053.     if (modes[unit - UNIT_OFFSET] == READ_EOF)
  1054.     return 1;
  1055.     return 0;
  1056. }
  1057. SHAR_EOF
  1058. if test 6129 -ne "`wc -c < '8080/io8080.c'`"
  1059. then
  1060.     echo shar: error transmitting "'8080/io8080.c'" '(should have been 6129 characters)'
  1061. fi
  1062. fi
  1063. echo shar: extracting "'8080/cret.asm'" '(478 characters)'
  1064. if test -f '8080/cret.asm'
  1065. then
  1066.     echo shar: will not over-write existing file "'8080/cret.asm'"
  1067. else
  1068. cat << \SHAR_EOF > '8080/cret.asm'
  1069. ;    Run time start off for Small C.
  1070.     cseg
  1071.     sphl        ; save the stack pointer
  1072.     shld    ?stksav
  1073.     lhld    6    ; pick up core top
  1074.     lxi    d,-10    ; decrease by 10 for safety
  1075.     dad    d
  1076.     sphl        ; set stack pointer
  1077.     call    stdioinit    ; initialize stdio
  1078.     call    Xarglist
  1079.     lhld    Xargc
  1080.     push    h
  1081.     lxi    h,Xargv
  1082.     push    h
  1083.     call    main    ; call main program
  1084.     pop    d
  1085.     pop    d
  1086.     lhld    ?stksav    ; restore stack pointer
  1087.     ret        ; go back to CCP
  1088.     dseg
  1089. ?stksav    ds    2
  1090.     extrn    stdioinit
  1091.     extrn    Xarglist
  1092.     extrn    Xargc
  1093.     extrn    Xargv
  1094.     extrn    main
  1095.     end
  1096. SHAR_EOF
  1097. if test 478 -ne "`wc -c < '8080/cret.asm'`"
  1098. then
  1099.     echo shar: error transmitting "'8080/cret.asm'" '(should have been 478 characters)'
  1100. fi
  1101. fi
  1102. echo shar: extracting "'8080/crun.asm'" '(4286 characters)'
  1103. if test -f '8080/crun.asm'
  1104. then
  1105.     echo shar: will not over-write existing file "'8080/crun.asm'"
  1106. else
  1107. cat << \SHAR_EOF > '8080/crun.asm'
  1108. ;
  1109. ;*****************************************************
  1110. ;                             *
  1111. ;    runtime    library    for small C compiler         *
  1112. ;                             *
  1113. ;    c.s - runtime routine for basic C code         *
  1114. ;                             *
  1115. ;        Ron Cain                 *
  1116. ;                             *
  1117. ;*****************************************************
  1118. ;
  1119.     cseg
  1120. ;
  1121.     public    ?gchar,?gint,?pchar,?pint
  1122.     public    ?sxt
  1123.     public    ?or,?and,?xor
  1124.     public    ?eq,?ne,?gt,?le,?ge,?lt,?uge,?ult,?ugt,?ule
  1125.     public    ?asr,?asl
  1126.     public    ?sub,?neg,?com,?lneg,?bool,?mul,?div
  1127.     public    ?case,brkend,Xstktop
  1128.     public    etext
  1129.     public    edata
  1130. ;
  1131. ; fetch char from (HL) and sign extend into HL
  1132. ?gchar:    mov    a,m
  1133. ?sxt:    mov    l,a
  1134.     rlc
  1135.     sbb    a
  1136.     mov    h,a
  1137.     ret
  1138. ; fetch int from (HL)
  1139. ?gint:    mov    a,m
  1140.     inx    h
  1141.     mov    h,m
  1142.     mov    l,a
  1143.     ret
  1144. ; store char from HL into (DE)
  1145. ?pchar: mov    a,l
  1146.     stax    d
  1147.     ret
  1148. ; store int from HL into (DE)
  1149. ?pint:    mov    a,l
  1150.     stax    d
  1151.     inx    d
  1152.     mov    a,h
  1153.     stax    d
  1154.     ret
  1155. ; "or" HL and DE into HL
  1156. ?or:    mov    a,l
  1157.     ora    e
  1158.     mov    l,a
  1159.     mov    a,h
  1160.     ora    d
  1161.     mov    h,a
  1162.     ret
  1163. ; "xor" HL and DE into HL
  1164. ?xor:    mov    a,l
  1165.     xra    e
  1166.     mov    l,a
  1167.     mov    a,h
  1168.     xra    d
  1169.     mov    h,a
  1170.     ret
  1171. ; "and" HL and DE into HL
  1172. ?and:    mov    a,l
  1173.     ana    e
  1174.     mov    l,a
  1175.     mov    a,h
  1176.     ana    d
  1177.     mov    h,a
  1178.     ret
  1179. ;
  1180. ;......logical operations: HL set to 0 (false) or 1 (true)
  1181. ;
  1182. ; DE == HL
  1183. ?eq:    call    ?cmp
  1184.     rz
  1185.     dcx    h
  1186.     ret
  1187. ; DE != HL
  1188. ?ne:    call    ?cmp
  1189.     rnz
  1190.     dcx    h
  1191.     ret
  1192. ; DE > HL [signed]
  1193. ?gt:    xchg
  1194.     call    ?cmp
  1195.     rc
  1196.     dcx    h
  1197.     ret
  1198. ; DE <= HL [signed]
  1199. ?le:    call    ?cmp
  1200.     rz
  1201.     rc
  1202.     dcx    h
  1203.     ret
  1204. ; DE >= HL [signed]
  1205. ?ge:    call    ?cmp
  1206.     rnc
  1207.     dcx    h
  1208.     ret
  1209. ; DE < HL [signed]
  1210. ?lt:    call    ?cmp
  1211.     rc
  1212.     dcx    h
  1213.     ret
  1214. ; DE >= HL [unsigned]
  1215. ?uge:    call    ?ucmp
  1216.     rnc
  1217.     dcx    h
  1218.     ret
  1219. ; DE < HL [unsigned]
  1220. ?ult:    call    ?ucmp
  1221.     rc
  1222.     dcx    h
  1223.     ret
  1224. ; DE > HL [unsigned]
  1225. ?ugt:    xchg
  1226.     call    ?ucmp
  1227.     rc
  1228.     dcx    h
  1229.     ret
  1230. ; DE <= HL [unsigned]
  1231. ?ule:    call    ?ucmp
  1232.     rz
  1233.     rc
  1234.     dcx    h
  1235.     ret
  1236. ; signed compare of DE and HL
  1237. ;   carry is sign of difference [set => DE < HL]
  1238. ;   zero is zero/non-zero
  1239. ?cmp:    mov    a,e
  1240.     sub    l
  1241.     mov    e,a
  1242.     mov    a,d
  1243.     sbb    h
  1244.     lxi    h,1        ;preset true
  1245.     jm    ?cmp1
  1246.     ora    e        ;resets carry
  1247.     ret
  1248. ?cmp1:    ora    e
  1249.     stc
  1250.     ret
  1251. ; unsigned compare of DE and HL
  1252. ;   carry is sign of difference [set => DE < HL]
  1253. ;   zero is zero/non-zero
  1254. ?ucmp:    mov    a,d
  1255.     cmp    h
  1256.     jnz    ?ucmp1
  1257.     mov    a,e
  1258.     cmp    l
  1259. ?ucmp1:    lxi    h,1        ;preset true
  1260.     ret
  1261. ; shift DE right arithmetically by HL, move to HL
  1262. ?asr:    xchg
  1263. ?asr1:    dcr    e
  1264.     rm
  1265.     mov    a,h
  1266.     ral
  1267.     mov    a,h
  1268.     rar
  1269.     mov    h,a
  1270.     mov    a,l
  1271.     rar
  1272.     mov    l,a
  1273.     jmp    ?asr1
  1274. ; shift DE left arithmetically by HL, move to HL
  1275. ?asl:    xchg
  1276. ?asl1:    dcr    e
  1277.     rm
  1278.     dad    h
  1279.     jmp    ?asl1
  1280. ; HL = DE - HL
  1281. ?sub:    mov    a,e
  1282.     sub    l
  1283.     mov    l,a
  1284.     mov    a,d
  1285.     sbb    h
  1286.     mov    h,a
  1287.     ret
  1288. ; HL = -HL
  1289. ?neg:    call    ?com
  1290.     inx    h
  1291.     ret
  1292. ; HL = ~HL
  1293. ?com:    mov    a,h
  1294.     cma
  1295.     mov    h,a
  1296.     mov    a,l
  1297.     cma
  1298.     mov    l,a
  1299.     ret
  1300. ; HL = !HL
  1301. ?lneg:    mov    a,h
  1302.     ora    l
  1303.     jz    ?lneg1
  1304.     lxi    h,0
  1305.     ret
  1306. ?lneg1:    inx    h
  1307.     ret
  1308. ; HL = !!HL
  1309. ?bool:    call    ?lneg
  1310.     jmp    ?lneg
  1311. ;
  1312. ; HL = DE * HL [signed]
  1313. ?mul:    mov    b,h
  1314.     mov    c,l
  1315.     lxi    h,0
  1316. ?mul1:    mov    a,c
  1317.     rrc
  1318.     jnc    ?mul2
  1319.     dad    d
  1320. ?mul2:    xra    a
  1321.     mov    a,b
  1322.     rar
  1323.     mov     b,a
  1324.     mov    a,c
  1325.     rar
  1326.     mov    c,a
  1327.     ora    b
  1328.     rz
  1329.     xra    a
  1330.     mov    a,e
  1331.     ral
  1332.     mov    e,a
  1333.     mov    a,d
  1334.     ral
  1335.     mov    d,a
  1336.     ora    e
  1337.     rz
  1338.     jmp    ?mul1
  1339. ; HL = DE / HL, DE = DE % HL
  1340. ?div:    mov    b,h
  1341.     mov    c,l
  1342.     mov    a,d
  1343.     xra    b
  1344.     push    psw
  1345.     mov    a,d
  1346.     ora    a
  1347.     cm    ?deneg
  1348.     mov    a,b
  1349.     ora    a
  1350.     cm    ?bcneg
  1351.     mvi    a,16
  1352.     push    psw
  1353.     xchg
  1354.     lxi    d,0
  1355. ?div1:    dad    h
  1356.     call    ?rdel
  1357.     jz    ?div2
  1358.     call    ?cmpbd
  1359.     jm    ?div2
  1360.     mov    a,l
  1361.     ori    1
  1362.     mov    l,a
  1363.     mov    a,e
  1364.     sub    c
  1365.     mov    e,a
  1366.     mov    a,d
  1367.     sbb    b
  1368.     mov    d,a
  1369. ?div2:    pop    psw
  1370.     dcr    a
  1371.     jz    ?div3
  1372.     push    psw
  1373.     jmp    ?div1
  1374. ?div3:    pop    psw
  1375.     rp
  1376.     call    ?deneg
  1377.     xchg
  1378.     call    ?deneg
  1379.     xchg
  1380.     ret
  1381. ; {DE = -DE}
  1382. ?deneg: mov    a,d
  1383.     cma
  1384.     mov    d,a
  1385.     mov    a,e
  1386.     cma
  1387.     mov    e,a
  1388.     inx    d
  1389.     ret
  1390. ; {BC = -BC}
  1391. ?bcneg: mov    a,b
  1392.     cma
  1393.     mov    b,a
  1394.     mov    a,c
  1395.     cma
  1396.     mov    c,a
  1397.     inx    b
  1398.     ret
  1399. ; {DE <r<r 1}
  1400. ?rdel:    mov    a,e
  1401.     ral
  1402.     mov    e,a
  1403.     mov    a,d
  1404.     ral
  1405.     mov    d,a
  1406.     ora    e
  1407.     ret
  1408. ; {BC : DE}
  1409. ?cmpbd: mov    a,e
  1410.     sub    c
  1411.     mov    a,d
  1412.     sbb    b
  1413.     ret
  1414. ; case jump
  1415. ?case:    xchg            ;switch value to DE
  1416.     pop    h        ;get table address
  1417. ?case1:    call    ?case4        ;get case value
  1418.     mov    a,e
  1419.     cmp    c        ;equal to switch value ?
  1420.     jnz    ?case2        ;no
  1421.     mov    a,d
  1422.     cmp    b        ;equal to switch value ?
  1423.     jnz    ?case2        ;no
  1424.     call    ?case4        ;get case label
  1425.     jz    ?case3        ;end of table, go to default
  1426.     push    b
  1427.     ret            ;case jump
  1428. ?case2:    call    ?case4        ;get case label
  1429.     jnz    ?case1        ;next case
  1430. ?case3:    dcx    h
  1431.     dcx    h
  1432.     dcx    h
  1433.     mov    d,m
  1434.     dcx    h
  1435.     mov    e,m
  1436.     xchg
  1437.     pchl            ;default jump
  1438. ?case4:    mov    c,m
  1439.     inx    h
  1440.     mov    b,m
  1441.     inx    h
  1442.     mov    a,c
  1443.     ora    b
  1444.     ret
  1445. ;
  1446. ;
  1447. ;
  1448. Xstktop:    lxi    h,0    ;return current stack pointer (for sbrk)
  1449.     dad    sp
  1450.     ret
  1451.     cseg
  1452. etext:
  1453.     dseg
  1454. brkend:    dw    edata        ;current "break"
  1455. edata:
  1456. ;
  1457. ;
  1458. ;
  1459.     end
  1460. SHAR_EOF
  1461. if test 4286 -ne "`wc -c < '8080/crun.asm'`"
  1462. then
  1463.     echo shar: error transmitting "'8080/crun.asm'" '(should have been 4286 characters)'
  1464. fi
  1465. fi
  1466. echo shar: done with directory "'8080'"
  1467. if test ! -d 'vax'
  1468. then
  1469.     echo shar: creating directory "'vax'"
  1470.     mkdir 'vax'
  1471. fi
  1472. echo shar: extracting "'vax/B2test.c'" '(655 characters)'
  1473. if test -f 'vax/B2test.c'
  1474. then
  1475.     echo shar: will not over-write existing file "'vax/B2test.c'"
  1476. else
  1477. cat << \SHAR_EOF > 'vax/B2test.c'
  1478. #include <stdio.h>
  1479.  
  1480. main () {
  1481.     FILE *infile; FILE *outfile;
  1482.     int c;
  1483.     puts("Starting input only");
  1484.     if ((infile = fopen("b2test.dat","r")) == NULL ) {
  1485.         puts("could not open input file");
  1486.         exit(1);
  1487.     }
  1488.     while (putchar(fgetc(infile)) != EOF);
  1489.     puts("end of input file");
  1490.     fclose(infile);
  1491.     puts("starting copy");
  1492.     if ((infile = fopen("b2test.dat","r")) == NULL) {
  1493.         puts("could not open input file for copy");
  1494.         exit(1);
  1495.     }
  1496.     if ((outfile = fopen("b2test.out","w")) == NULL) {
  1497.         puts("could not open output file");
  1498.         exit(1);
  1499.     }
  1500.     while ((c = fgetc(infile)) != EOF) {
  1501.         fputc(c, outfile);
  1502.     }
  1503.     puts("finished output file");
  1504.     fclose(infile);
  1505.     fclose(outfile);
  1506. }
  1507. SHAR_EOF
  1508. if test 655 -ne "`wc -c < 'vax/B2test.c'`"
  1509. then
  1510.     echo shar: error transmitting "'vax/B2test.c'" '(should have been 655 characters)'
  1511. fi
  1512. fi
  1513. echo shar: extracting "'vax/Makefile'" '(169 characters)'
  1514. if test -f 'vax/Makefile'
  1515. then
  1516.     echo shar: will not over-write existing file "'vax/Makefile'"
  1517. else
  1518. cat << \SHAR_EOF > 'vax/Makefile'
  1519. .SUFFIXES:    .o .c
  1520.  
  1521. .c.o:
  1522.     /u/clewis/lib/sccvax -c $*.c
  1523.     as -o $*.o $*.s
  1524.  
  1525. OBJ    = crunvax.o chiovax.o iovax.o
  1526.  
  1527. libl.a:    $(OBJ) crt0.o
  1528.     ar ru libl.a $(OBJ)
  1529.     ucb ranlib libl.a
  1530. SHAR_EOF
  1531. if test 169 -ne "`wc -c < 'vax/Makefile'`"
  1532. then
  1533.     echo shar: error transmitting "'vax/Makefile'" '(should have been 169 characters)'
  1534. fi
  1535. fi
  1536. echo shar: extracting "'vax/b2test.dat'" '(12 characters)'
  1537. if test -f 'vax/b2test.dat'
  1538. then
  1539.     echo shar: will not over-write existing file "'vax/b2test.dat'"
  1540. else
  1541. cat << \SHAR_EOF > 'vax/b2test.dat'
  1542. ehllo
  1543. hello
  1544. SHAR_EOF
  1545. if test 12 -ne "`wc -c < 'vax/b2test.dat'`"
  1546. then
  1547.     echo shar: error transmitting "'vax/b2test.dat'" '(should have been 12 characters)'
  1548. fi
  1549. fi
  1550. echo shar: extracting "'vax/chiovax.c'" '(488 characters)'
  1551. if test -f 'vax/chiovax.c'
  1552. then
  1553.     echo shar: will not over-write existing file "'vax/chiovax.c'"
  1554. else
  1555. cat << \SHAR_EOF > 'vax/chiovax.c'
  1556. #define EOL 10
  1557. getchar() {
  1558. #asm
  1559.     movl    $0,r0
  1560.     pushl    $1
  1561.     pushal    buff
  1562.     pushl    $0
  1563.     calls    $3,Xread
  1564.     cvtbl    buff,r0
  1565.     .data
  1566. buff:    .space 1
  1567.     .text
  1568. #endasm
  1569. }
  1570.  
  1571. #asm
  1572.     .set    read,3
  1573. Xread:
  1574.     .word    0x0000
  1575.     chmk    $read
  1576.     bcc     noerror2
  1577.     jmp     cerror
  1578. noerror2:
  1579.     ret
  1580. cerror:    bpt
  1581. #endasm
  1582.  
  1583. putchar (c) char c; {
  1584.     c;
  1585. #asm
  1586.     cvtlb    r0,buff
  1587.     pushl    $1
  1588.     pushal    buff
  1589.     pushl    $1
  1590.     calls    $3,Xwrite
  1591.     cvtbl    buff,r0
  1592. #endasm
  1593. }
  1594.  
  1595. #asm
  1596.     .set    write,4
  1597. Xwrite:
  1598.     .word    0x0000
  1599.     chmk    $write
  1600.     bcc     noerror
  1601.     jmp     cerror
  1602. noerror:
  1603.     ret
  1604. #endasm
  1605. SHAR_EOF
  1606. if test 488 -ne "`wc -c < 'vax/chiovax.c'`"
  1607. then
  1608.     echo shar: error transmitting "'vax/chiovax.c'" '(should have been 488 characters)'
  1609. fi
  1610. fi
  1611. echo shar: extracting "'vax/crt0.c'" '(362 characters)'
  1612. if test -f 'vax/crt0.c'
  1613. then
  1614.     echo shar: will not over-write existing file "'vax/crt0.c'"
  1615. else
  1616. cat << \SHAR_EOF > 'vax/crt0.c'
  1617. #asm
  1618. # C runtime startoff
  1619.  
  1620.     .set    exit,1
  1621. .globl    start
  1622. .globl    _main
  1623. .globl    _exit
  1624.  
  1625. #
  1626. #    C language startup routine
  1627.  
  1628. start:
  1629.     .word    0x0000
  1630.     subl2    $8,sp
  1631.     movl    8(sp),4(sp)  #  argc
  1632.     movab    12(sp),r0
  1633.     movl    r0,(sp)  #  argv
  1634.     jsb    _main
  1635.     addl2    $8,sp
  1636.     pushl    r0
  1637.     chmk    $exit
  1638. #endasm
  1639. exit(x) int x; {
  1640.     x;
  1641. #asm
  1642.     pushl    r0
  1643.     calls    $1,exit2
  1644. exit2:
  1645.     .word    0x0000
  1646.     chmk    $exit
  1647. #endasm
  1648. }
  1649. SHAR_EOF
  1650. if test 362 -ne "`wc -c < 'vax/crt0.c'`"
  1651. then
  1652.     echo shar: error transmitting "'vax/crt0.c'" '(should have been 362 characters)'
  1653. fi
  1654. fi
  1655. echo shar: extracting "'vax/crt0.s'" '(760 characters)'
  1656. if test -f 'vax/crt0.s'
  1657. then
  1658.     echo shar: will not over-write existing file "'vax/crt0.s'"
  1659. else
  1660. cat << \SHAR_EOF > 'vax/crt0.s'
  1661. #    Small C VAX
  1662. #    Coder (2.1,83/04/05)
  1663. #    Front End (2.1,83/03/20)
  1664.     .globl    lneg
  1665.     .globl    case
  1666.     .globl    eq
  1667.     .globl    ne
  1668.     .globl    lt
  1669.     .globl    le
  1670.     .globl    gt
  1671.     .globl    ge
  1672.     .globl    ult
  1673.     .globl    ule
  1674.     .globl    ugt
  1675.     .globl    uge
  1676.     .globl    bool
  1677.     .text
  1678. ##asm
  1679. # C runtime startoff
  1680.     .set    exit,1
  1681. .globl    start
  1682. .globl    _main
  1683. .globl    _exit
  1684. #
  1685. #    C language startup routine
  1686. start:
  1687.     .word    0x0000
  1688.     subl2    $8,sp
  1689.     movl    8(sp),4(sp)  #  argc
  1690.     movab    12(sp),r0
  1691.     movl    r0,(sp)  #  argv
  1692.     jsb    _main
  1693.     addl2    $8,sp
  1694.     pushl    r0
  1695.     chmk    $exit
  1696. #exit(x) int x; {
  1697.     .align    1
  1698. _exit:
  1699.  
  1700. #    x;
  1701.     moval    4(sp),r0
  1702.     movl    (r0),r0
  1703. ##asm
  1704.     pushl    r0
  1705.     calls    $1,exit2
  1706. exit2:
  1707.     .word    0x0000
  1708.     chmk    $exit
  1709. #}
  1710. LL1:
  1711.  
  1712.     rsb
  1713.     .data
  1714.     .globl    _etext
  1715.     .globl    _edata
  1716.     .globl    _exit
  1717.  
  1718. #0 error(s) in compilation
  1719. #    literal pool:0
  1720. #    global pool:42
  1721. #    Macro pool:43
  1722. SHAR_EOF
  1723. if test 760 -ne "`wc -c < 'vax/crt0.s'`"
  1724. then
  1725.     echo shar: error transmitting "'vax/crt0.s'" '(should have been 760 characters)'
  1726. fi
  1727. fi
  1728. echo shar: extracting "'vax/crunvax.c'" '(1268 characters)'
  1729. if test -f 'vax/crunvax.c'
  1730. then
  1731.     echo shar: will not over-write existing file "'vax/crunvax.c'"
  1732. else
  1733. cat << \SHAR_EOF > 'vax/crunvax.c'
  1734. #asm
  1735. #    csa09 Small C v1 comparison support
  1736. #    All are dyadic except for lneg.
  1737. .globl    eq
  1738. .globl    ne
  1739. .globl    lt
  1740. .globl    le
  1741. .globl    gt
  1742. .globl    ge
  1743. .globl    ult
  1744. .globl    ule
  1745. .globl    ugt
  1746. .globl    uge
  1747. .globl    lneg
  1748. .globl    bool
  1749. .globl    case
  1750. .globl    _Xstktop
  1751.  
  1752. eq:    cmpl    r0,4(sp)
  1753.     jeql    true
  1754.     jbr    false
  1755.  
  1756. ne:    cmpl    r0,4(sp)
  1757.     jneq    true
  1758.     jbr    false
  1759.  
  1760. lt:    cmpl    r0,4(sp)
  1761.     jgtr    true
  1762.     jbr    false
  1763.  
  1764. le:    cmpl    r0,4(sp)
  1765.     jgeq    true
  1766.     jbr    false
  1767.  
  1768. gt:    cmpl    r0,4(sp)
  1769.     jlss    true
  1770.     jbr    false
  1771.  
  1772. ge:    cmpl    r0,4(sp)
  1773.     jleq    true
  1774.     jbr    false
  1775.  
  1776. ult:    cmpl    r0,4(sp)
  1777.     jgtru    true
  1778.     jbr    false
  1779.  
  1780. ule:    cmpl    r0,4(sp)
  1781.     jgequ    true
  1782.     jbr    false
  1783.  
  1784. ugt:    cmpl    r0,4(sp)
  1785.     jlequ    true
  1786.     jbr    false
  1787.  
  1788. uge:    cmpl    r0,4(sp)
  1789.     jlssu    true
  1790.     jbr    false
  1791.  
  1792. lneg:    cmpl    r0,$0
  1793.     jeql    ltrue
  1794.     movl    $0,r0
  1795.     rsb
  1796. ltrue:    movl    $1,r0
  1797.     rsb
  1798.  
  1799. bool:    jsb    lneg
  1800.     jbr    lneg
  1801.  
  1802. true:    movl    $1,r0
  1803.     movl    (sp),r3
  1804.     addl2    $8,sp
  1805.     jmp    (r3)
  1806.  
  1807. false:    movl    $0,r0
  1808.     movl    (sp),r3
  1809.     addl2    $8,sp
  1810.     jmp    (r3)
  1811. _Xstktop:    movl    sp,r0
  1812.     rsb
  1813. #    Case jump, value is in r0, case table in (sp)
  1814. case:    movl    (sp)+,r1    # pick up case pointer
  1815. casl:
  1816.     movl    (r1)+,r2    # pick up value.
  1817.     movl    (r1)+,r3    # pick up label.
  1818.     bneq    notdef        # if not default, check it
  1819.     jmp    (r2)        # is default, go do it.
  1820. notdef:    cmpl    r0,r2        # compare table value with switch value
  1821.     bneq    casl        # go for next table ent if not
  1822.     jmp    (r3)        # otherwise, jump to it.
  1823. #endasm
  1824. SHAR_EOF
  1825. if test 1268 -ne "`wc -c < 'vax/crunvax.c'`"
  1826. then
  1827.     echo shar: error transmitting "'vax/crunvax.c'" '(should have been 1268 characters)'
  1828. fi
  1829. fi
  1830. echo shar: extracting "'vax/iovax.c'" '(1593 characters)'
  1831. if test -f 'vax/iovax.c'
  1832. then
  1833.     echo shar: will not over-write existing file "'vax/iovax.c'"
  1834. else
  1835. cat << \SHAR_EOF > 'vax/iovax.c'
  1836. /*    VAX fopen, fclose, fgetc, fputc, feof
  1837.  * gawd is this gross - no buffering!
  1838. */
  1839. #include <stdio.h>
  1840.  
  1841. static    feofed[20];
  1842. static    char    charbuf[1];
  1843. static    retcode;
  1844.  
  1845. fopen(filnam, mod) char *filnam, *mod; {
  1846.     if (*mod == 'w') {
  1847.         filnam;
  1848. #asm
  1849.         pushl    r0
  1850.         calls    $1,zunlink
  1851. #endasm
  1852.         filnam;
  1853. #asm
  1854.         pushl    $0644
  1855.         pushl    r0
  1856.         calls    $2,zcreat
  1857.         movl    r0,_retcode
  1858. #endasm
  1859.         if (retcode < 0) {
  1860.             return(NULL);
  1861.         } else return(retcode);
  1862.     }
  1863.     filnam;
  1864. #asm
  1865.     pushl    $0    # read mode
  1866.     pushl    r0
  1867.     calls    $2,zopen
  1868.     movl    r0,_retcode
  1869. #endasm
  1870.     feofed[retcode] = 0;
  1871.     if (retcode < 0) return (NULL);
  1872.     else return(retcode);
  1873. }
  1874.  
  1875. fclose(unit) int unit; {
  1876.     unit;
  1877. #asm
  1878.     pushl    r0
  1879.     calls    $1,zclose
  1880. #endasm
  1881. }
  1882.  
  1883. fgetc(unit) int unit; {
  1884.     unit;
  1885. #asm
  1886.     pushl    $1
  1887.     pushl    $_charbuf
  1888.     pushl    r0
  1889.     calls    $3,zread
  1890.     movl    r0,_retcode
  1891. #endasm
  1892.     if (retcode <= 0) {
  1893.         feofed[unit] = 1;
  1894.         return(EOF);
  1895.     } else
  1896.         return(charbuf[0]);
  1897. }
  1898.  
  1899. fputc(c, unit) int c, unit; {
  1900.     charbuf[0] = c;
  1901.     unit;
  1902. #asm
  1903.     pushl    $1
  1904.     pushl    $_charbuf
  1905.     pushl    r0
  1906.     calls    $3,zwrite
  1907. #endasm
  1908.     return(c);
  1909. }
  1910.  
  1911. feof(unit) int unit; {
  1912.     if (feofed[unit]) return(1);
  1913.     else return(NULL);
  1914. }
  1915.  
  1916. /*    Assembler assists    */
  1917. #asm
  1918.     .set    unlink,10
  1919.     .set    creat,8
  1920.     .set    open,5
  1921.     .set    close,6
  1922.     .set    read,3
  1923.     .set    write,4
  1924. zunlink:
  1925.     .word    0x0000
  1926.     chmk    $unlink
  1927.     bcc    noerr
  1928.     jmp    cerror
  1929. zcreat:
  1930.     .word    0x0000
  1931.     chmk    $creat
  1932.     bcc    noerr
  1933.     jmp    cerror
  1934. zopen:
  1935.     .word    0x0000
  1936.     chmk    $open
  1937.     bcc    noerr
  1938.     jmp    cerror
  1939. zclose:
  1940.     .word    0x0000
  1941.     chmk    $close
  1942.     bcc    noerr
  1943.     jmp    cerror
  1944. zread:
  1945.     .word    0x0000
  1946.     chmk    $read
  1947.     bcc    noerr
  1948.     jmp    cerror
  1949. zwrite:
  1950.     .word    0x0000
  1951.     chmk    $write
  1952.     bcc    noerr
  1953.     jmp    cerror
  1954.  
  1955. cerror:
  1956.     mnegl    $1,r0
  1957.     ret
  1958. noerr:    ret
  1959. #endasm
  1960. SHAR_EOF
  1961. if test 1593 -ne "`wc -c < 'vax/iovax.c'`"
  1962. then
  1963.     echo shar: error transmitting "'vax/iovax.c'" '(should have been 1593 characters)'
  1964. fi
  1965. fi
  1966. echo shar: extracting "'vax/optest.c'" '(2294 characters)'
  1967. if test -f 'vax/optest.c'
  1968. then
  1969.     echo shar: will not over-write existing file "'vax/optest.c'"
  1970. else
  1971. cat << \SHAR_EOF > 'vax/optest.c'
  1972. #include <stdio.h>
  1973. #define    chkstk    1
  1974. #define    NOSUP    1
  1975. int address;
  1976. int ret;
  1977. int locaddr;
  1978. int i;
  1979. int *temp;
  1980. #ifdef    vax
  1981. #define INTSIZE 4
  1982. #else
  1983. #define    INTSIZE    2
  1984. #endif
  1985. int    fred[30];
  1986. main(){
  1987.     int x;
  1988.     puts("Starting test");
  1989.     i = 1;
  1990.     address = &x;
  1991.     locaddr = 0;
  1992.     address = address + INTSIZE;
  1993.     temp = address;
  1994.     ret = *temp;
  1995.     fred[3] = 3;
  1996.     test(fred[3], 3, "fred[3] = 3");
  1997.     test(INTSIZE, sizeof(int), "INTSIZE");
  1998.     test(sizeof(char), 1, "sizeof char");
  1999.     test(1 + 4, 1,  "(should fail) 1+4");
  2000.     test(1022 + 5, 1027, "1022 + 5");
  2001.     test(4 + 5, 9, "4 + 5");
  2002.     test(1022 * 3, 3066, "1022 * 3");
  2003.     test(4 * - 1, -4, "4 * - 1");
  2004.     test(4 * 5, 20, "4 * 5");
  2005.     test(1000 - 999, 1, "1000 - 999");
  2006.     test(1000 - 1200, -200, "1000 - 1200");
  2007.     test(-1 - -1, 0, "-1 - -1");
  2008.     test(4 >> 2, 1, "4 >> 2");
  2009.     test(1234 >> 1, 617, "1234 >> 1");
  2010.     test(4 << 2, 16, "4 << 2");
  2011.     test(1000 << 1, 2000, "1000 << 1");
  2012.     test(1001 % 10, 1, "1001 % 10");
  2013.     test(3 % 10, 3, "3 % 10");
  2014.     test(10 % 4, 2, "10 % 4");
  2015.     test(1000 / 5, 200, "1000 / 5");
  2016.     test(3 / 10, 0, "3 / 10");
  2017.     test(10 / 3, 3, "10 / 3");
  2018.     test(1000 == 32767, 0, "1000 == 32767");
  2019.     test(1000 == 1000, 1, "1000 == 1000");
  2020.     test(1 != 0, 1, "1 != 0");
  2021.     test(1 < -1, 0, "1 < -1");
  2022.     test(1 < 2, 1, "1 < 2");
  2023.     test(1 != 1, 0, "1 != 1");
  2024.     test(2 && 1, 1, "2 && 1");
  2025.     test(0 && 1, 0, "0 && 1");
  2026.     test(1 && 0, 0, "1 && 0");
  2027.     test(0 && 0, 0, "0 && 0");
  2028.     test(1000 || 1, 1, "1000 || 1");
  2029.     test(1000 || 0, 1, "1000 || 0");
  2030.     test(0 || 1, 1, "0 || 1");
  2031.     test(0 || 0, 0, "0 || 0");
  2032.     test(!2, 0, "!2");
  2033.     test(!0, 1, "!0");
  2034.     test(~1, -2, "~1");
  2035.     test(2 ^ 1, 3, "2 ^ 1");
  2036.     test(0 ^ 0, 0, "0 ^ 0");
  2037.     test(1 ^ 1, 0, "1 ^ 1");
  2038.     test(5 ^ 6, 3, "5 ^ 6");
  2039.     test((0 < 1) ? 1 : 0, 1, "(0 < 1) ? 1 : 0");
  2040.     test((1000 > 1000) ? 0: 1, 1, "(1000 > 1000) ? 0 : 1");
  2041.     puts("ending test");
  2042.     }
  2043. test(t, real, testn) int t; char *testn; int real;{
  2044.     if (t != real) {
  2045.         fputs(testn, stdout);
  2046.         fputs(" failed\n", stdout);
  2047.         fputs("Should be: ", stdout);
  2048.         printn(real, 10, stdout);
  2049.         fputs(" was: ", stdout);
  2050.         printn(t, 10, stdout);
  2051.         putchar('\n');
  2052.         prompt();
  2053.         }
  2054.     if (*temp != ret) {
  2055.         puts("retst");
  2056.         prompt();
  2057.     }
  2058. #ifdef    chkstk
  2059.     if (locaddr == 0) locaddr = &t;
  2060.     else if (locaddr != &t) {
  2061.         puts("locst during");
  2062.         puts(testn);
  2063.         prompt();
  2064.     }
  2065. #endif
  2066. }
  2067. prompt() {
  2068.     puts("hit any key to continue");
  2069.     getchar();
  2070. }
  2071.  
  2072. SHAR_EOF
  2073. if test 2294 -ne "`wc -c < 'vax/optest.c'`"
  2074. then
  2075.     echo shar: error transmitting "'vax/optest.c'" '(should have been 2294 characters)'
  2076. fi
  2077. fi
  2078. echo shar: extracting "'vax/vscc'" '(151 characters)'
  2079. if test -f 'vax/vscc'
  2080. then
  2081.     echo shar: will not over-write existing file "'vax/vscc'"
  2082. else
  2083. cat << \SHAR_EOF > 'vax/vscc'
  2084. if ../src/sccvax -c $1.c
  2085.     then
  2086.     if as -o $1.o $1.s
  2087.         then
  2088.         rm $1.s
  2089.         ld -o $1 ../crunvax/crt0.o $1.o ../libc/vaxlibc.a ../crunvax/libl.a
  2090.     fi
  2091. fi
  2092. SHAR_EOF
  2093. if test 151 -ne "`wc -c < 'vax/vscc'`"
  2094. then
  2095.     echo shar: error transmitting "'vax/vscc'" '(should have been 151 characters)'
  2096. fi
  2097. fi
  2098. echo shar: done with directory "'vax'"
  2099. if test ! -d 'lib'
  2100. then
  2101.     echo shar: creating directory "'lib'"
  2102.     mkdir 'lib'
  2103. fi
  2104. echo shar: extracting "'lib/Makefile'" '(815 characters)'
  2105. if test -f 'lib/Makefile'
  2106. then
  2107.     echo shar: will not over-write existing file "'lib/Makefile'"
  2108. else
  2109. cat << \SHAR_EOF > 'lib/Makefile'
  2110. .SUFFIXES:    .o .obj .c .asm
  2111.  
  2112. .c.o:
  2113.     ../src/sccvax $*.c
  2114.     as -o $*.o $*.s
  2115.     rm $*.s
  2116. ASSEMS =\
  2117.     abs.asm        atoi.asm       binary.asm\
  2118.     charclass.asm  fgets.asm      fputs.asm\
  2119.     getchar.asm    gets.asm       index.asm\
  2120.     itoa.asm       printn.asm     putchar.asm\
  2121.     puts.asm       reverse.asm    shell.asm\
  2122.     strcat.asm     strcmp.asm     strcpy.asm\
  2123.     strlen.asm     rand.asm \
  2124.     strncat.asm strncmp.asm strncpy.asm
  2125.  
  2126. OBJ =\
  2127.     abs.o        atoi.o       binary.o\
  2128.     charclass.o  fgets.o      fputs.o\
  2129.     getchar.o    gets.o       index.o\
  2130.     itoa.o       printn.o     putchar.o\
  2131.     puts.o       reverse.o    shell.o\
  2132.     strcat.o     strcmp.o     strcpy.o\
  2133.     strlen.o     rand.o \
  2134.     strncat.o strncmp.o strncpy.o
  2135. .c.asm:
  2136.     ../src/scc8080 $*.c
  2137.     mv $*.s $*.asm
  2138.  
  2139. all:    $(ASSEMS)
  2140.  
  2141. vaxlibc.a:    $(OBJ)
  2142.     ar ur vaxlibc.a  $(OBJ)
  2143.     ranlib vaxlibc.a
  2144. SHAR_EOF
  2145. if test 815 -ne "`wc -c < 'lib/Makefile'`"
  2146. then
  2147.     echo shar: error transmitting "'lib/Makefile'" '(should have been 815 characters)'
  2148. fi
  2149. fi
  2150. echo shar: extracting "'lib/abs.c'" '(114 characters)'
  2151. if test -f 'lib/abs.c'
  2152. then
  2153.     echo shar: will not over-write existing file "'lib/abs.c'"
  2154. else
  2155. cat << \SHAR_EOF > 'lib/abs.c'
  2156. /*    abs (num) return absolute value */
  2157. abs(num) int num;{
  2158.     if (num < 0) return (-num);
  2159.     else         return (num);
  2160.     }
  2161. SHAR_EOF
  2162. if test 114 -ne "`wc -c < 'lib/abs.c'`"
  2163. then
  2164.     echo shar: error transmitting "'lib/abs.c'" '(should have been 114 characters)'
  2165. fi
  2166. fi
  2167. echo shar: extracting "'lib/atoi.c'" '(322 characters)'
  2168. if test -f 'lib/atoi.c'
  2169. then
  2170.     echo shar: will not over-write existing file "'lib/atoi.c'"
  2171. else
  2172. cat << \SHAR_EOF > 'lib/atoi.c'
  2173. #include <stdio.h>
  2174. #define EOL 10
  2175. atoi(s) char s[];{
  2176.     int i,n,sign;
  2177.     for (i=0;
  2178.         (s[i] == ' ') | (s[i] == EOL) | (s[i] == '\t');
  2179.         ++i) ;
  2180.     sign = 1;
  2181.     switch(s[i]){
  2182.     case '-': sign = -1; /* and fall through */
  2183.     case '+': ++i;
  2184.         break;
  2185.     }
  2186.     for(n = 0;
  2187.         isdigit(s[i]);
  2188.         ++i)
  2189.         n = 10 * n + s[i] - '0';
  2190.     return (sign * n);
  2191. }
  2192. SHAR_EOF
  2193. if test 322 -ne "`wc -c < 'lib/atoi.c'`"
  2194. then
  2195.     echo shar: error transmitting "'lib/atoi.c'" '(should have been 322 characters)'
  2196. fi
  2197. fi
  2198. echo shar: extracting "'lib/binary.c'" '(412 characters)'
  2199. if test -f 'lib/binary.c'
  2200. then
  2201.     echo shar: will not over-write existing file "'lib/binary.c'"
  2202. else
  2203. cat << \SHAR_EOF > 'lib/binary.c'
  2204. /* binary search for string word in table[0] .. table[n-1] 
  2205.  *    reference CPL pg. 125
  2206.  */
  2207. #include <stdio.h>
  2208. binary(word, table, n)
  2209. char *word;
  2210. int    table[];
  2211. int n;{
  2212.     int low, high, mid, cond;
  2213.     low = 0;
  2214.     high = n - 1;
  2215.     while (low <= high){
  2216.         mid = (low + high) / 2;
  2217.         if ((cond = strcmp(word, table[mid])) < 0)
  2218.             high = mid - 1;
  2219.         else if (cond > 0)
  2220.             low = mid + 1;
  2221.         else
  2222.             return (mid);
  2223.         }
  2224.     return (-1);
  2225.     }
  2226. SHAR_EOF
  2227. if test 412 -ne "`wc -c < 'lib/binary.c'`"
  2228. then
  2229.     echo shar: error transmitting "'lib/binary.c'" '(should have been 412 characters)'
  2230. fi
  2231. fi
  2232. echo shar: extracting "'lib/charclass.c'" '(588 characters)'
  2233. if test -f 'lib/charclass.c'
  2234. then
  2235.     echo shar: will not over-write existing file "'lib/charclass.c'"
  2236. else
  2237. cat << \SHAR_EOF > 'lib/charclass.c'
  2238. isalpha(c) char c;{
  2239.     if ((c >= 'a' & c <= 'z') |
  2240.         (c >= 'A' & c <= 'Z'))    return(1);
  2241.     else                return(0);
  2242.     }
  2243.  
  2244. isupper(c) char c;{
  2245.     if (c >= 'A' & c <= 'Z')    return(1);
  2246.     else                return(0);
  2247.     }
  2248.  
  2249. islower(c) char c;{
  2250.     if (c >= 'a' & c <= 'z')    return(1);
  2251.     else                return(0);
  2252.     }
  2253.  
  2254. isdigit(c) char c;{
  2255.     if (c >= '0' & c <= '9')    return(1);
  2256.     else                return(0);
  2257.     }
  2258.  
  2259. isspace(c) char c;{
  2260.     if (c == ' ' | c == '\t' | c == '\n')    return(1);
  2261.     else                    return(0);
  2262.     }
  2263.  
  2264. toupper(c) char c;{
  2265.     return ((c >= 'a' && c <= 'z') ? c - 32: c);
  2266.     }
  2267.  
  2268. tolower(c) char c;{
  2269.     return((c >= 'A' && c <= 'Z') ? c + 32: c);
  2270.     }
  2271. SHAR_EOF
  2272. if test 588 -ne "`wc -c < 'lib/charclass.c'`"
  2273. then
  2274.     echo shar: error transmitting "'lib/charclass.c'" '(should have been 588 characters)'
  2275. fi
  2276. fi
  2277. echo shar: extracting "'lib/fgets.c'" '(302 characters)'
  2278. if test -f 'lib/fgets.c'
  2279. then
  2280.     echo shar: will not over-write existing file "'lib/fgets.c'"
  2281. else
  2282. cat << \SHAR_EOF > 'lib/fgets.c'
  2283. /*
  2284. #include    <stdio.h>
  2285. */
  2286. #define NULL 0
  2287. #define FILE char
  2288.  
  2289. fgets(s, n, iop)
  2290. int n;
  2291. char *s;
  2292. register FILE *iop;
  2293. {
  2294.     register c;
  2295.     register char *cs;
  2296.  
  2297.     cs = s;
  2298.     while (--n>0 && (c = fgetc(iop))>=0) {
  2299.         *cs++ = c;
  2300.         if (c=='\n')
  2301.             break;
  2302.     }
  2303.     if (c<0 && cs==s)
  2304.         return(NULL);
  2305.     *cs++ = '\0';
  2306.     return(s);
  2307. }
  2308. SHAR_EOF
  2309. if test 302 -ne "`wc -c < 'lib/fgets.c'`"
  2310. then
  2311.     echo shar: error transmitting "'lib/fgets.c'" '(should have been 302 characters)'
  2312. fi
  2313. fi
  2314. echo shar: extracting "'lib/fputs.c'" '(92 characters)'
  2315. if test -f 'lib/fputs.c'
  2316. then
  2317.     echo shar: will not over-write existing file "'lib/fputs.c'"
  2318. else
  2319. cat << \SHAR_EOF > 'lib/fputs.c'
  2320. #include <stdio.h>
  2321.  
  2322. fputs(str, fp) FILE *fp; char *str; {
  2323.     while(*str) fputc(*str++, fp);
  2324. }
  2325. SHAR_EOF
  2326. if test 92 -ne "`wc -c < 'lib/fputs.c'`"
  2327. then
  2328.     echo shar: error transmitting "'lib/fputs.c'" '(should have been 92 characters)'
  2329. fi
  2330. fi
  2331. echo shar: extracting "'lib/getchar.c'" '(56 characters)'
  2332. if test -f 'lib/getchar.c'
  2333. then
  2334.     echo shar: will not over-write existing file "'lib/getchar.c'"
  2335. else
  2336. cat << \SHAR_EOF > 'lib/getchar.c'
  2337. #include <stdio.h>
  2338. getchar() {
  2339.     return(fgetc(stdin));
  2340. }
  2341. SHAR_EOF
  2342. if test 56 -ne "`wc -c < 'lib/getchar.c'`"
  2343. then
  2344.     echo shar: error transmitting "'lib/getchar.c'" '(should have been 56 characters)'
  2345. fi
  2346. fi
  2347. echo shar: extracting "'lib/gets.c'" '(451 characters)'
  2348. if test -f 'lib/gets.c'
  2349. then
  2350.     echo shar: will not over-write existing file "'lib/gets.c'"
  2351. else
  2352. cat << \SHAR_EOF > 'lib/gets.c'
  2353. #include <stdio.h>
  2354. #define EOL    10
  2355. #define    BKSP    8
  2356. #define CTRLU    0x15
  2357. gets(s) char *s; {
  2358.     char c, *ts;
  2359.     ts = s;
  2360.     while ((c = getchar()) != EOL && (c != EOF)) {
  2361.         if (c == BKSP) {
  2362.             if (ts > s) {
  2363.                 --ts;
  2364.                 /* CPM already echoed */
  2365.                 putchar(' ');
  2366.                 putchar(BKSP);
  2367.                 }
  2368.             }
  2369.         else if (c == CTRLU) {
  2370.             ts = s;
  2371.             putchar(EOL);
  2372.             putchar('#');
  2373.             }
  2374.         else (*ts++) = c;
  2375.         }
  2376.     if ((c == EOF) && (ts == s)) return NULL;
  2377.     (*ts) = NULL;
  2378.     return s;
  2379. }
  2380. SHAR_EOF
  2381. if test 451 -ne "`wc -c < 'lib/gets.c'`"
  2382. then
  2383.     echo shar: error transmitting "'lib/gets.c'" '(should have been 451 characters)'
  2384. fi
  2385. fi
  2386. echo shar: extracting "'lib/index.c'" '(284 characters)'
  2387. if test -f 'lib/index.c'
  2388. then
  2389.     echo shar: will not over-write existing file "'lib/index.c'"
  2390. else
  2391. cat << \SHAR_EOF > 'lib/index.c'
  2392. /*    index - find index of string t in s
  2393.  *    reference CPL 67.
  2394.  */
  2395. #include <stdio.h>
  2396. #define EOS 0
  2397. index(s, t)
  2398. char s[], t[];{
  2399.     int i, j, k;
  2400.     for (i = 0; s[i] != EOS; i++){
  2401.         k=0;
  2402.         for (j=i;t[k]!=EOS & s[j]==t[k]; i++)
  2403.             j++;
  2404.             ;
  2405.         if (t[k] == EOS)
  2406.             return(i);
  2407.         }
  2408.     return(-1);
  2409.     }
  2410. SHAR_EOF
  2411. if test 284 -ne "`wc -c < 'lib/index.c'`"
  2412. then
  2413.     echo shar: error transmitting "'lib/index.c'" '(should have been 284 characters)'
  2414. fi
  2415. fi
  2416. echo shar: extracting "'lib/itoa.c'" '(224 characters)'
  2417. if test -f 'lib/itoa.c'
  2418. then
  2419.     echo shar: will not over-write existing file "'lib/itoa.c'"
  2420. else
  2421. cat << \SHAR_EOF > 'lib/itoa.c'
  2422. #include <stdio.h>
  2423. #define EOS 0
  2424. itoa(n,s) char s[];int n;{
  2425.     int i,sign;
  2426.     if((sign = n) < 0) n = -n;
  2427.     i = 0;
  2428.     do {
  2429.         s[i++] = n % 10 + '0';
  2430.      }while ((n = n/10) > 0);
  2431.     if (sign < 0) s[i++] = '-';
  2432.     s[i] = EOS;
  2433.     reverse(s);
  2434. }
  2435. SHAR_EOF
  2436. if test 224 -ne "`wc -c < 'lib/itoa.c'`"
  2437. then
  2438.     echo shar: error transmitting "'lib/itoa.c'" '(should have been 224 characters)'
  2439. fi
  2440. fi
  2441. echo shar: extracting "'lib/lorder8080'" '(350 characters)'
  2442. if test -f 'lib/lorder8080'
  2443. then
  2444.     echo shar: will not over-write existing file "'lib/lorder8080'"
  2445. else
  2446. cat << \SHAR_EOF > 'lib/lorder8080'
  2447. grep public $* | sed 's/:    public//
  2448. /?/d
  2449. s?\([^     ]*\)[     ]*\(.*\)?\2    \1?
  2450. s/\.asm//'> /tmp/symdef$$
  2451. grep extrn $* | sed 's/:    extrn//
  2452. s/\.asm//
  2453. s?\([^     ]*\)[     ]*\(.*\)?\2    \1?
  2454. /?/d'    > /tmp/symref$$
  2455. sort /tmp/symdef$$ -o /tmp/symdef$$
  2456. sort /tmp/symref$$ -o /tmp/symref$$
  2457. join /tmp/symref$$ /tmp/symdef$$ | sed 's/[^     ]* *//'
  2458. rm /tmp/symdef$$ /tmp/symref$$
  2459. SHAR_EOF
  2460. if test 350 -ne "`wc -c < 'lib/lorder8080'`"
  2461. then
  2462.     echo shar: error transmitting "'lib/lorder8080'" '(should have been 350 characters)'
  2463. fi
  2464. fi
  2465. echo shar: extracting "'lib/printn.c'" '(371 characters)'
  2466. if test -f 'lib/printn.c'
  2467. then
  2468.     echo shar: will not over-write existing file "'lib/printn.c'"
  2469. else
  2470. cat << \SHAR_EOF > 'lib/printn.c'
  2471. #include <stdio.h>
  2472. /* print a number in any radish */
  2473. #define DIGARR "0123456789ABCDEF"
  2474. printn(number, radix, file)
  2475. int number, radix; FILE *file;{
  2476.     int i;
  2477.     char *digitreps;
  2478.     if (number < 0 & radix == 10){
  2479.         fputc('-', file);
  2480.         number = -number;
  2481.         }
  2482.     if ((i = number / radix) != 0)
  2483.         printn(i, radix, file);
  2484.     digitreps=DIGARR;
  2485.     fputc(digitreps[number % radix], file);
  2486.     }
  2487. SHAR_EOF
  2488. if test 371 -ne "`wc -c < 'lib/printn.c'`"
  2489. then
  2490.     echo shar: error transmitting "'lib/printn.c'" '(should have been 371 characters)'
  2491. fi
  2492. fi
  2493. echo shar: extracting "'lib/putchar.c'" '(68 characters)'
  2494. if test -f 'lib/putchar.c'
  2495. then
  2496.     echo shar: will not over-write existing file "'lib/putchar.c'"
  2497. else
  2498. cat << \SHAR_EOF > 'lib/putchar.c'
  2499. #include <stdio.h>
  2500. putchar(c) char c; {
  2501.     return fputc(c, stdout);
  2502. }
  2503. SHAR_EOF
  2504. if test 68 -ne "`wc -c < 'lib/putchar.c'`"
  2505. then
  2506.     echo shar: error transmitting "'lib/putchar.c'" '(should have been 68 characters)'
  2507. fi
  2508. fi
  2509. echo shar: extracting "'lib/puts.c'" '(105 characters)'
  2510. if test -f 'lib/puts.c'
  2511. then
  2512.     echo shar: will not over-write existing file "'lib/puts.c'"
  2513. else
  2514. cat << \SHAR_EOF > 'lib/puts.c'
  2515. #include <stdio.h>
  2516. #define EOL 10
  2517. puts(str) char *str;{
  2518.     while (*str) putchar(*str++);
  2519.     putchar(EOL);
  2520.     }
  2521. SHAR_EOF
  2522. if test 105 -ne "`wc -c < 'lib/puts.c'`"
  2523. then
  2524.     echo shar: error transmitting "'lib/puts.c'" '(should have been 105 characters)'
  2525. fi
  2526. fi
  2527. echo shar: extracting "'lib/rand.c'" '(216 characters)'
  2528. if test -f 'lib/rand.c'
  2529. then
  2530.     echo shar: will not over-write existing file "'lib/rand.c'"
  2531. else
  2532. cat << \SHAR_EOF > 'lib/rand.c'
  2533.  
  2534. int xxseed;
  2535.  
  2536. srand (x) int x; {
  2537.     xxseed = x;
  2538. }
  2539.  
  2540. rand () {
  2541.     xxseed = xxseed * 251 + 123;
  2542.     if (xxseed < 0) xxseed = - xxseed;
  2543.     return (xxseed);
  2544. }
  2545.  
  2546. getrand () {
  2547.     puts ("Type a character");
  2548.     return (getchar() * 123);
  2549. }
  2550. SHAR_EOF
  2551. if test 216 -ne "`wc -c < 'lib/rand.c'`"
  2552. then
  2553.     echo shar: error transmitting "'lib/rand.c'" '(should have been 216 characters)'
  2554. fi
  2555. fi
  2556. echo shar: extracting "'lib/reverse.c'" '(229 characters)'
  2557. if test -f 'lib/reverse.c'
  2558. then
  2559.     echo shar: will not over-write existing file "'lib/reverse.c'"
  2560. else
  2561. cat << \SHAR_EOF > 'lib/reverse.c'
  2562. #include <stdio.h>
  2563. /* Reverse a character string, reference CPL p 59 */
  2564. reverse(s)
  2565. char *s;{
  2566.     int i, j;
  2567.     char c;
  2568.     i = 0;
  2569.     j = strlen(s) - 1;
  2570.     while (i < j){
  2571.         c = s[i];
  2572.         s[i] = s[j];
  2573.         s[j] = c;
  2574.         i++;
  2575.         j--;
  2576.         }
  2577.     return(s);
  2578.     }
  2579. SHAR_EOF
  2580. if test 229 -ne "`wc -c < 'lib/reverse.c'`"
  2581. then
  2582.     echo shar: error transmitting "'lib/reverse.c'" '(should have been 229 characters)'
  2583. fi
  2584. fi
  2585. echo shar: extracting "'lib/sbrk.c'" '(244 characters)'
  2586. if test -f 'lib/sbrk.c'
  2587. then
  2588.     echo shar: will not over-write existing file "'lib/sbrk.c'"
  2589. else
  2590. cat << \SHAR_EOF > 'lib/sbrk.c'
  2591. extern char *brkend;
  2592. sbrk (incr) char *incr; {
  2593.     char *stktop;
  2594.  
  2595.     stktop = Xstktop() - 200;
  2596.  
  2597.     /* do we have enough space? */
  2598.     if (brkend + incr < stktop) {
  2599.         stktop = brkend;
  2600.         brkend = brkend + incr;
  2601.         return (stktop);
  2602.     }
  2603.     else
  2604.         return (-1);
  2605. }
  2606. SHAR_EOF
  2607. if test 244 -ne "`wc -c < 'lib/sbrk.c'`"
  2608. then
  2609.     echo shar: error transmitting "'lib/sbrk.c'" '(should have been 244 characters)'
  2610. fi
  2611. fi
  2612. echo shar: extracting "'lib/shell.c'" '(395 characters)'
  2613. if test -f 'lib/shell.c'
  2614. then
  2615.     echo shar: will not over-write existing file "'lib/shell.c'"
  2616. else
  2617. cat << \SHAR_EOF > 'lib/shell.c'
  2618. /* Shell sort of string v[0] .... v[n-1] into increasing
  2619.  * order.
  2620.  *    Reference CPL pg. 108.
  2621.  */
  2622.  
  2623. shellsort(v, n)
  2624. int v[];
  2625. int n;
  2626.     {
  2627.     int gap, i, j;
  2628.     char *temp;
  2629.     for (gap = n/2; gap > 0; gap = gap / 2)
  2630.         for (i = gap; i < n; i++)
  2631.             for (j = i - gap; j >= 0; j = j - gap){
  2632.                 if (strcmp(v[j], v[j+gap]) <= 0)
  2633.                     break;
  2634.                 temp = v[j];
  2635.                 v[j] = v[j + gap];
  2636.                 v[j + gap] = temp;
  2637.                 }
  2638.     }
  2639. SHAR_EOF
  2640. if test 395 -ne "`wc -c < 'lib/shell.c'`"
  2641. then
  2642.     echo shar: error transmitting "'lib/shell.c'" '(should have been 395 characters)'
  2643. fi
  2644. fi
  2645. echo shar: extracting "'lib/strcat.c'" '(218 characters)'
  2646. if test -f 'lib/strcat.c'
  2647. then
  2648.     echo shar: will not over-write existing file "'lib/strcat.c'"
  2649. else
  2650. cat << \SHAR_EOF > 'lib/strcat.c'
  2651. /*
  2652.  * Concatenate s2 on the end of s1.  S1's space must be large enough.
  2653.  * Return s1.
  2654.  */
  2655.  
  2656. strcat(s1, s2)
  2657. char *s1, *s2;
  2658. {
  2659.     char *os1;
  2660.  
  2661.     os1 = s1;
  2662.     while (*s1++)
  2663.         ;
  2664.     *--s1;
  2665.     while (*s1++ = *s2++)
  2666.         ;
  2667.     return(os1);
  2668. }
  2669. SHAR_EOF
  2670. if test 218 -ne "`wc -c < 'lib/strcat.c'`"
  2671. then
  2672.     echo shar: error transmitting "'lib/strcat.c'" '(should have been 218 characters)'
  2673. fi
  2674. fi
  2675. echo shar: extracting "'lib/strcmp.c'" '(174 characters)'
  2676. if test -f 'lib/strcmp.c'
  2677. then
  2678.     echo shar: will not over-write existing file "'lib/strcmp.c'"
  2679. else
  2680. cat << \SHAR_EOF > 'lib/strcmp.c'
  2681. /*
  2682.  * Compare strings:  s1>s2: >0  s1==s2: 0  s1<s2: <0
  2683.  */
  2684.  
  2685. strcmp(s1, s2)
  2686. char *s1, *s2;
  2687. {
  2688.  
  2689.     while (*s1 == *s2++)
  2690.         if (*s1++=='\0')
  2691.             return(0);
  2692.     return(*s1 - *--s2);
  2693.     }
  2694. SHAR_EOF
  2695. if test 174 -ne "`wc -c < 'lib/strcmp.c'`"
  2696. then
  2697.     echo shar: error transmitting "'lib/strcmp.c'" '(should have been 174 characters)'
  2698. fi
  2699. fi
  2700. echo shar: extracting "'lib/strcpy.c'" '(190 characters)'
  2701. if test -f 'lib/strcpy.c'
  2702. then
  2703.     echo shar: will not over-write existing file "'lib/strcpy.c'"
  2704. else
  2705. cat << \SHAR_EOF > 'lib/strcpy.c'
  2706. #include <stdio.h>
  2707. /*
  2708.  * Copy string s2 to s1.  s1 must be large enough.
  2709.  * return s1
  2710.  */
  2711.  
  2712. strcpy(s1, s2)
  2713. char *s1, *s2;
  2714. {
  2715.     char *os1;
  2716.  
  2717.     os1 = s1;
  2718.     while (*s1++ = *s2++)
  2719.         ;
  2720.     return(os1);
  2721. }
  2722. SHAR_EOF
  2723. if test 190 -ne "`wc -c < 'lib/strcpy.c'`"
  2724. then
  2725.     echo shar: error transmitting "'lib/strcpy.c'" '(should have been 190 characters)'
  2726. fi
  2727. fi
  2728. echo shar: extracting "'lib/strlen.c'" '(140 characters)'
  2729. if test -f 'lib/strlen.c'
  2730. then
  2731.     echo shar: will not over-write existing file "'lib/strlen.c'"
  2732. else
  2733. cat << \SHAR_EOF > 'lib/strlen.c'
  2734. #include <stdio.h>
  2735. /* return length of string, reference CPL p 36 */
  2736. strlen(s) char *s;{
  2737.     int i;
  2738.     i = 0;
  2739.     while (*s++) i++;
  2740.     return (i);
  2741.     }
  2742. SHAR_EOF
  2743. if test 140 -ne "`wc -c < 'lib/strlen.c'`"
  2744. then
  2745.     echo shar: error transmitting "'lib/strlen.c'" '(should have been 140 characters)'
  2746. fi
  2747. fi
  2748. echo shar: extracting "'lib/strncat.c'" '(330 characters)'
  2749. if test -f 'lib/strncat.c'
  2750. then
  2751.     echo shar: will not over-write existing file "'lib/strncat.c'"
  2752. else
  2753. cat << \SHAR_EOF > 'lib/strncat.c'
  2754. /*
  2755.  * Concatenate s2 on the end of s1.  S1's space must be large enough.
  2756.  * At most n characters are moved.
  2757.  * Return s1.
  2758.  */
  2759.  
  2760. strncat(s1, s2, n)
  2761. register char *s1, *s2;
  2762. register n;
  2763. {
  2764.     register char *os1;
  2765.  
  2766.     os1 = s1;
  2767.     while (*s1++)
  2768.         ;
  2769.     --s1;
  2770.     while (*s1++ = *s2++)
  2771.         if (--n < 0) {
  2772.             *--s1 = '\0';
  2773.             break;
  2774.         }
  2775.     return(os1);
  2776. }
  2777. SHAR_EOF
  2778. if test 330 -ne "`wc -c < 'lib/strncat.c'`"
  2779. then
  2780.     echo shar: error transmitting "'lib/strncat.c'" '(should have been 330 characters)'
  2781. fi
  2782. fi
  2783. echo shar: extracting "'lib/strncmp.c'" '(226 characters)'
  2784. if test -f 'lib/strncmp.c'
  2785. then
  2786.     echo shar: will not over-write existing file "'lib/strncmp.c'"
  2787. else
  2788. cat << \SHAR_EOF > 'lib/strncmp.c'
  2789. /*
  2790.  * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
  2791.  */
  2792.  
  2793. strncmp(s1, s2, n)
  2794. char *s1, *s2;
  2795. int n;
  2796. {
  2797.  
  2798.     while (--n >= 0 && *s1 == *s2++)
  2799.         if (*s1++ == '\0')
  2800.             return(0);
  2801.     return(n<0 ? 0 : *s1 - *--s2);
  2802. }
  2803. SHAR_EOF
  2804. if test 226 -ne "`wc -c < 'lib/strncmp.c'`"
  2805. then
  2806.     echo shar: error transmitting "'lib/strncmp.c'" '(should have been 226 characters)'
  2807. fi
  2808. fi
  2809. echo shar: extracting "'lib/strncpy.c'" '(309 characters)'
  2810. if test -f 'lib/strncpy.c'
  2811. then
  2812.     echo shar: will not over-write existing file "'lib/strncpy.c'"
  2813. else
  2814. cat << \SHAR_EOF > 'lib/strncpy.c'
  2815. /*
  2816.  * Copy s2 to s1, truncating or null-padding to always copy n bytes
  2817.  * return s1
  2818.  */
  2819.  
  2820. strncpy(s1, s2, n)
  2821. char *s1, *s2;
  2822. int n;
  2823. {
  2824.     register i;
  2825.     register char *os1;
  2826.  
  2827.     os1 = s1;
  2828.     for (i = 0; i < n; i++)
  2829.         if ((*s1++ = *s2++) == '\0') {
  2830.             while (++i < n)
  2831.                 *s1++ = '\0';
  2832.             return(os1);
  2833.         }
  2834.     return(os1);
  2835. }
  2836. SHAR_EOF
  2837. if test 309 -ne "`wc -c < 'lib/strncpy.c'`"
  2838. then
  2839.     echo shar: error transmitting "'lib/strncpy.c'" '(should have been 309 characters)'
  2840. fi
  2841. fi
  2842. echo shar: done with directory "'lib'"
  2843. exit 0
  2844. #    End of shell archive
  2845.